<?php
// +----------------------------------------------------------------------
// | 多客怪兽框架多平台开发框架 [ 以下开发工具自动生成-版权勿删 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021~2024 http://www.dkyx.cc All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 刘泓宾（514660094@qq.com）
// +----------------------------------------------------------------------

namespace addons\cloud_market\model;


/**
 * 附件分组模型文件
 * Create by :  刘泓宾<514660094@qq.com>
 * Copyright :  copyright (c) 多客怪兽, www.dkyx.cc
 */
class CloudMarketAttachmentGroup extends CloudMarketBaseModel
{

    // 字段自动类型转换
    protected $type = array(

    );
    // 数据输出需要追加的属性
    protected $append = array(

    );
    public function __construct(array $data = [])
    {
        parent::__construct($data);
    }


    /**
     * 数据新增前执行
     * Create by :  刘泓宾<514660094@qq.com>
     * @param \think\Model $model
     * @return void
     */
    public static function onBeforeInsert(\think\Model $model)
    {
        parent::onBeforeInsert($model);
        // 权重自增
        $model->weigh = self::order('weigh', "desc")->value('weigh') + 1;
    }

    /**
     * 关联CloudMarketUser模型
     * Create by :  刘泓宾<514660094@qq.com>
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(CloudMarketUser::class, 'user_id', 'id');
    }

}
